-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Rework Ipv6Addr::is_global
to check for global reachability rather than global scope
#86634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
library/std/src/net/ip.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reworded to a (in my opinion) less cluttered non-exhaustive list. Instead of trying to list every type of address and exceptions, we list the most notable ones (mostly the ones Rust has methods for) and refer to the Special Address Registry for the complete overview. A similar thing is done in the description of Ipv6Addr::is_global
.
library/std/src/net/ip.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reordered the checks to match the order in the Special Address Registry.
library/std/src/net/ip.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"globally reachable" instead of "globally routable", as that is the terminology used in the Special Address Registry.
library/std/src/net/ip.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're not connected to the internet, you still can't reach a "globally reachable" address. I hope this also makes it clear that this method doesn't actually do any network traffic.
library/std/src/net/ip.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to avoid the confusion between "globally reachable" and "global scope", the rename in #85696 from is_unicast_global
to has_unicast_global_scope
should hopefully help with this. Another possibility would be to rename is_global
to is_globally_reachable
.
library/std/src/net/ip/tests.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the PR description, multicast addresses with non-global scope are actually still globally reachable.
dabff95
to
2be1e92
Compare
2be1e92
to
9ddd5a5
Compare
Addressed an incorrect check pointed out in #86969 (comment) |
☔ The latest upstream changes (presumably #87535) made this pull request unmergeable. Please resolve the merge conflicts. |
…plett Add `Ipv6Addr::is_benchmarking` This PR adds the unstable method `Ipv6Addr::is_benchmarking`. This method is added for parity with `Ipv4Addr::is_benchmarking`, and I intend to use it in a future rework of `Ipv6Addr::is_global` (edit: rust-lang#86634) to more accurately follow the [IANA Special Address Registry](https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml) (like is done in `Ipv4Addr::is_global`). With `Ipv6Addr::is_benchmarking` and `Ipv4Addr::is_benchmarking` now both existing, `IpAddr::is_benchmarking` is also added.
…plett Add `Ipv6Addr::is_benchmarking` This PR adds the unstable method `Ipv6Addr::is_benchmarking`. This method is added for parity with `Ipv4Addr::is_benchmarking`, and I intend to use it in a future rework of `Ipv6Addr::is_global` (edit: rust-lang#86634) to more accurately follow the [IANA Special Address Registry](https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml) (like is done in `Ipv4Addr::is_global`). With `Ipv6Addr::is_benchmarking` and `Ipv4Addr::is_benchmarking` now both existing, `IpAddr::is_benchmarking` is also added.
Ping from triage: |
…se, r=Mark-Simulacrum Rework Ipv6Addr::is_global to check for global reachability rather than global scope - rebase Rebasing of pull request rust-lang#86634 off of master to try and get the feature "ip" stabilized. I also found a test failure in the rebase that is_global was considering the benchmark space to be globally reachable. This is related to my other rebasing pull request rust-lang#99947
This PR changes the unstable method
Ipv6Addr::is_global
to make it consistent withIpv4Addr::is_global
, checking for reachability rather than global scope (see also #85696 fixing this conflation inIpv6Addr::is_unicast_global
).To summarize, there are two concepts; an address can be globally reachable, and an address can have global scope. These concepts have been conflated in the past, but are not the same thing. There exist addresses with global scope that are not globally reachable (for example unique local addresses), and addresses that are globally reachable without having global scope (multicast addresses with non-global scope).
is_unicast_global
should be used to check for global scope, andis_global
for global reachability according to the IANA IPv6 Special-Purpose Address Registry, like is done inIpv4Addr::is_global
and other language implementations. (To prevent this confusion in the future, #85696 renamesis_unicast_global
tohas_unicast_global_scope
)The documentation of
Ipv4Addr::is_global
is also updated to make the two methods have similar descriptions and examples.